package com.cjz.demo3;

/**
 * lambda表达式之实战
 */
public class Test {
    public static void main(String[] args) {

        CJZButton test = new CJZButton();
        test.setOnClickListener(new CJZOnClickListener() {//设置监听
            @Override
            public void onClick() {
                System.out.println("button pressed 1");
            }
        });
        new Thread(new Runnable() {//模拟用户点击事件
            @Override
            public void run() {
                test.press();
            }
        }).start();


        //lambda表达式简化
        CJZButton test2 = new CJZButton();
        test2.setOnClickListener(() -> System.out.println("button pressed 2"));
        new Thread(test2::press).start();

    }
}
